package com.monlyu.action.notice;

import com.monlyu.action.BaseAction;
import com.monlyu.annotation.ActionAnno;
import com.monlyu.bo.NoticeBo;
import com.monlyu.bo.RoleBo;
import com.monlyu.vo.Notice;

/*        
 * @creator   曾俊 
 * @create-time 2010-2-6 下午05:40:11    
 */
public class EditNoticeAction extends BaseAction {

	private RoleBo roleBo;
	
	private Notice notice;

	private NoticeBo noticeBo;

	public void setRoleBo(RoleBo roleBo) {
		this.roleBo = roleBo;
	}

	public Notice getNotice() {
		return notice;
	}

	public void setNotice(Notice notice) {
		this.notice = notice;
	}

	public void setNoticeBo(NoticeBo noticeBo) {
		this.noticeBo = noticeBo;
	}

	@ActionAnno(readOnly = false)
	public String execute() {
		roleBo.checkPermission("NOTICE_MANAGE");
		if (notice.getId() == null) {
			noticeBo.insert(notice);
		} else {
			noticeBo.update(notice);
		}
		return ajax("操作成功！");
	}

	public String toEdit() {
		roleBo.checkPermission("NOTICE_MANAGE");
		if (notice != null) {
			noticeBo.load(notice);
		}
		return view("noticeForm.jsp");
	}

	@ActionAnno(readOnly = false)
	public String delete() {
		roleBo.checkPermission("NOTICE_MANAGE");
		noticeBo.delete(notice);
		return ajax();
	}
	
	public String show() {
		noticeBo.load(notice);
		return view("noticeDetail.jsp");
	}

}
